Foundational API Designs
Learn about foundational design problems.
We'll cover the following
The earlier chapters enabled learners to understand most of the preliminary concepts required to design an API. Now, we’ll utilize that knowledge to use the REDCAMEL approach to designing an API. Let's start by understanding the need to design foundational problems.
Introduction#
Different applications offer a particular set of services. For example, both YouTube and LeetCode use the search functionality. To design these services, we need to include all the functionalities required for that service. Instead of repeating such functionalities in each design, we define them as foundational design problems and use them as building blocks in relevant design problems.
The foundational design problems are primarily building blocks without which the entire service is incomplete. The purpose of separately designing foundational problems is to thoroughly discuss them once and then reuse them where they are applicable. Moreover, it will be easier for learners to tackle relatively simple design problems first and get a glimpse of our approach for designing a specific API.
This lesson will outline different foundational problems we’ll design and use as building blocks for our main design problems. We’ll discuss the following outlined foundational problems in detail:
-
Design a Search Service: This problem allows us to design an API for the search functionality. It demonstrates how the API gateway can interact with multiple services to obtain search results with ads and recommendations based on a search query.
Additionally, we discuss how to make a paginating API and perform versioning by giving an example of adding filter functionality to the search service. Almost every advanced design problem, like YouTube, Google maps, Uber, LeetCode, etc., uses search functionality.
- Design a File Service: The file API enables users to store different media, such as images, videos, documents, software, etc., into cloud storage, which can be accessed on demand. We’ll design this service as a building block for storing or retrieving files in some of the major design problems. For example, YouTube API uses it to upload user videos to the platform.
- Design a Comment Service: In this design problem, we model an API for a comment service. This API interlinks various components in a comment system and directs various operations relevant to a comment, such as create, retrieve, delete, or edit a comment. For example, it’s used in the discussion service of the LeetCode API.
- Design a Pub-sub Service: The pub-sub demonstrates the need to opt for an event-driven architecture over a request-response architecture. We’ll design this service as a building block to represent an advanced implementation of event-driven architecture to decouple microservices. It will be used as a notification service for some of the major design problems.
Although we have few foundational design problems, we’ll see their use repeatedly in advanced design problems in one way or another. For example, the pub-sub API serves not only as a notification system but also as a decoupling layer for a microservice architecture in most design problems, such as Stripe, LeetCode, Gaming, and so on.
Conventions for the Design Chapters of the Course
Requirements of the Search API